package com.xuecheng.manage_cms.service.impl;

import com.xuecheng.framework.domain.system.SysDictionary;
import com.xuecheng.framework.exception.ExceptionCast;
import com.xuecheng.framework.model.response.CommonCode;
import com.xuecheng.framework.model.response.QueryResponseResult;
import com.xuecheng.manage_cms.dao.SysDictionaryRepository;
import com.xuecheng.manage_cms.service.SysDictionaryService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Kidy
 * @date 2020/6/19 20:07
 */
@Service
public class SysDictionaryServiceImpl implements SysDictionaryService {

    @Autowired
    private SysDictionaryRepository sysDictionaryRepository;

    @Override
    public SysDictionary findByType(String type) {
        if (StringUtils.isBlank(type)) {
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        }
        List<SysDictionary> list = sysDictionaryRepository.findBydType(type);
        if (null == list || list.size() <= 0) {
            ExceptionCast.cast(CommonCode.INVALID_PARAM);
        }
        return list.get(0);
    }
}
